package com.rongzhe.house.presenter;

import android.content.Intent;

import com.rongzhe.house.entity.voo.User;
import com.rongzhe.house.internet.DataListener;
import com.rongzhe.house.manager.UserManager;
import com.rongzhe.house.ui.UiControlInterface;
import com.rongzhe.house.ui.fragment.UserCenterFragment;

/**
 * Created by huang on 2017/12/10.
 */

public class UserCenterPresenter extends BasePresenter {
    public UserCenterPresenter(UiControlInterface uiControlInterface) {
        super(uiControlInterface);
    }

    @Override
    public void start(Intent intent) {
        //如果没有登录什么都不做
        if (!UserManager.getInstance().isLogin()) {
            return;
        }
        UserManager.getInstance().getUserInfo(new DataListener<User>() {
            @Override
            public void onSuccess(User data, String message) {
                ((UserCenterFragment)getUiControlInterface()).showUserInfo(data);
            }

            @Override
            public void onFailed(Throwable error, String message) {
            }

            @Override
            public void onEnd() {
            }
        });
    }
}
